package com.asia5b.a5mall.middleware.base

import android.content.Context
import android.view.Gravity
import android.view.WindowManager
import com.asia5b.a5mall.middleware.R
import kotlinx.android.synthetic.main.loading_dialog.*

/**
 * Created by zhangyuncai on 2018/9/11.
 */
class LoadingDialog(context: Context) : BaseDialog(context, R.style.LoadingDialogTheme) {
    override var widthStyle: Int = WindowManager.LayoutParams.WRAP_CONTENT
    override var gravity: Int = Gravity.CENTER
    override var layoutId: Int = R.layout.loading_dialog
    override var animations: Int = R.style.DialogScaleAnimation
    var message: String? = null
        set(value) {
            setView()
            field = value
        }

    override fun initView() {
        setView()
    }

    private fun setView() {
        tv_loadingname?.text = if (message.isNullOrEmpty()) getString(R.string.加载中) else message
    }

    override fun setWindowsStyle() {
        super.setWindowsStyle()
        //解决 状态栏变色的bug
        window!!.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
    }

    override fun initEvent() {}
}